package com.chinasi.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.caland.framework.core.page.Pager;
import com.chinasi.dao.ConsumerBasicDao;
import com.chinasi.model.ConsumerBasic;
import com.chinasi.service.ConsumerBasicService;

@Service
public class ConsumerBasicServiceImpl implements ConsumerBasicService {

	/**
	 * ConsumerBasicDAO
	 */
	@Autowired
	private ConsumerBasicDao consumerBasicDao;

	@Override
	public Pager findPageCondition(ConsumerBasic searchBean, int currentPage) {
		Pager pager = new Pager(consumerBasicDao.getTotalCount(searchBean),currentPage);
		if(pager.getTotalPages() >= currentPage)
			pager.setData(consumerBasicDao.findByCondition(searchBean, pager.getStartRow(), pager.getPageSize()));
		return pager;
	}

	@Override
	public ConsumerBasic findById(String id) {
		return consumerBasicDao.findByPK(id, ConsumerBasic.class);
	}

	@Override
	public int findTotalCount() {
		return consumerBasicDao.getTotalCount(new ConsumerBasic());
	}

}
